package com.ATMgui;

import com.lovo.util.Util;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class ATM extends JFrame implements ActionListener {
    private CardLayout cardLayout = new CardLayout();
    private Login login = new Login(this);
    private Menu menu = new Menu(this);
    private GetMoney getMoney = new GetMoney();
    private Image bgimg = Util.getImage("/image/background.jpg");


    @Override
    public void actionPerformed(ActionEvent e) {

    }

    public ATM() {
        this.setContentPane(new JPanel() {
            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(bgimg, 0, 0, 800, 600, this);
            }
        });
        this.setLayout(cardLayout);
        //登陆按钮
//        this.add("登陆", login);
//        this.add("菜单", menu);
        this.add("取钱", getMoney);


        this.setSize(800, 600);
        this.setTitle("ATM");
        this.setLocationRelativeTo(null);
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setVisible(true);
    }

    public static void main(String[] args) {
        new ATM();
    }

    public void switchPanel(String name) {
        cardLayout.show(this.getContentPane(), name);
    }
}
